﻿using System;

namespace Terraria.World.Generation
{
	// Token: 0x020000B0 RID: 176
	public static class Passes
	{
		// Token: 0x020000B1 RID: 177
		public class Clear : GenPass
		{
			// Token: 0x06000A7A RID: 2682 RVA: 0x0000B435 File Offset: 0x00009635
			public Clear() : base("clear", 1f)
			{
			}

			// Token: 0x06000A7B RID: 2683 RVA: 0x003E62B4 File Offset: 0x003E44B4
			public override void Apply(GenerationProgress progress)
			{
				for (int i = 0; i < GenBase._worldWidth; i++)
				{
					for (int j = 0; j < GenBase._worldHeight; j++)
					{
						if (GenBase._tiles[i, j] == null)
						{
							GenBase._tiles[i, j] = new Tile();
						}
						else
						{
							GenBase._tiles[i, j].ClearEverything();
						}
					}
				}
			}
		}

		// Token: 0x020000B2 RID: 178
		public class ScatterCustom : GenPass
		{
			// Token: 0x06000A7C RID: 2684 RVA: 0x0000B447 File Offset: 0x00009647
			public ScatterCustom(string name, float loadWeight, int count, GenBase.CustomPerUnitAction perUnit = null) : base(name, loadWeight)
			{
				this._perUnit = perUnit;
				this._count = count;
			}

			// Token: 0x06000A7D RID: 2685 RVA: 0x0000B460 File Offset: 0x00009660
			public void SetCustomAction(GenBase.CustomPerUnitAction perUnit)
			{
				this._perUnit = perUnit;
			}

			// Token: 0x06000A7E RID: 2686 RVA: 0x003E6314 File Offset: 0x003E4514
			public override void Apply(GenerationProgress progress)
			{
				int i = this._count;
				while (i > 0)
				{
					if (this._perUnit(GenBase._random.Next(1, GenBase._worldWidth), GenBase._random.Next(1, GenBase._worldHeight), new object[0]))
					{
						i--;
					}
				}
			}

			// Token: 0x04000EE3 RID: 3811
			private GenBase.CustomPerUnitAction _perUnit;

			// Token: 0x04000EE4 RID: 3812
			private int _count;
		}
	}
}
